#include <iostream>
#include "tree_structures.h"
#include <boost/thread.hpp>
#include <windows.h>
#include <queue>
#include <stack>

#define INDEXID 0
#define LEAFID 1


using namespace std;

class Index {
boost::shared_mutex mutex;	//mutex used for concurrent access by multiple threads
const int d;
Node * root;
queue<Node *> queue1;
stack<stackElement *> stack1;
stackElement * stackFirst;

//Index Print Helper Functions
void printKeysNode(Node *);
void printLevel();
void resetQueue();
void addNodesToQueue(IndexNode *);
void resetStack();
void printKeys();

public:
//constructors for default case of d=64 or one set by user
Index(int d): d(d) {
	root = new LeafNode(d);
	stackFirst = new stackElement();
	stackFirst->node = root;
	stackFirst->index = 0;
	stack1.push(stackFirst);
	queue1.push(root);
}

Index(): d(64) {
	root = new LeafNode(64);
	stackFirst = new stackElement();
	stackFirst->node = root;
	stackFirst->index = 0;
	stack1.push(stackFirst);
	queue1.push(root);
}

//Core index functions
void printIndex();
Record *searchRecord(int searchKey);
int insertRecord(int, Record *);

};

